package cn.tedu.health.controller;

import cn.tedu.health.pojo.entity.Recommendations;
import cn.tedu.health.response.JsonResult;
import cn.tedu.health.service.IRecommendationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

@RestController
@RequestMapping("/api")
public class RecommendationsController {

    @Autowired
    private IRecommendationsService recommendationsService;

    @PostMapping("/recommendations")
    public JsonResult createRecommendations(@RequestBody Recommendations recommendations) {
        recommendationsService.createRecommendations(recommendations);
        return JsonResult.ok();
    }

    @GetMapping("/recommendations")
    public JsonResult getRecommendations(@RequestParam Long userId, @RequestParam LocalDate date) {
        Recommendations recommendations = recommendationsService.getRecommendations(userId, date);
        return JsonResult.ok(recommendations);
    }
}
